package com.mrx.pvzcommunity.model.user;


import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@Data
@ApiModel(value = "最多信息的 用户对象")
@NoArgsConstructor
public class User implements Serializable {

    @ApiModelProperty(value = "用户 邮箱", example = "1@qq.com")
    private String mail;

    public User(long account, String password) {
        this.account = account;
        this.password = password;
    }

    @ApiModelProperty(value = "用户 账号", example = "1")
    private long account;
    @ApiModelProperty(value = "用户 密码", example = "123456")
    private String password;

    @ApiModelProperty(value = "用户 密保问题", example = "问题嗷")
    private String problem;
    @ApiModelProperty(value = "用户 密保答案", example = "答案嗷")
    private String answer;

    @ApiModelProperty(value = "用户 ID", example = "1", hidden = true)
    private long uid;
    @ApiModelProperty(value = "用户 昵称", example = "nickName")
    private String uname;

    public boolean canRegister() {
        return account > 100 && password != null && uname != null && mail != null && problem != null && answer != null;
    }

    public NormalUser toNormalUser() {
        return new NormalUser(this);
    }

    public AvatarUser toAvatarUser() {
        return new AvatarUser(this);
    }
}
